<?php

namespace Xin\ChatGPT\Channels\Zhipu;

use Xin\ChatGPT\Channels\AbstractChannel;
use Xin\ChatGPT\Contracts\Completion as CompletionContract;
use Xin\ChatGPT\Contracts\File as FileContract;
use Xin\ChatGPT\Contracts\Model as ModelContract;

class Channel extends AbstractChannel
{
    public const DEFAULT_MODEL = 'glm-4v';

    /**
     * @inerhitDoc
     */
    public function completion(): CompletionContract
    {
        return new Completion($this->client, $this);
    }

    /**
     * @inerhitDoc
     */
    public function model(): ModelContract
    {
        return new Model($this->client);
    }

    /**
     * @inerhitDoc
     */
    public function file(): FileContract
    {
        return new File($this->client);
    }

    /**
     * @inerhitDoc
     */
    public function balance()
    {
        // TODO: Implement balance() method.
    }

    /**
     * @inerhitDoc
     */
    protected function getHttpClientDefaultOptions(): array
    {
        return array_merge(parent::getHttpClientDefaultOptions(), [
            'base_uri' => 'https://open.bigmodel.cn/api/paas/v4/',
            'headers' => [
                'Authorization' => 'Bearer ' . $this->config['key'],
            ],
        ]);
    }
}
